<template>
  <div>
    <el-button @click="generate">新的一局</el-button>
    <template v-for="(e, i) in booms">
      <el-button :key="i" :type="e !== 9 ? 'info' : 'danger'"
        >{{ e }}
      </el-button>
    </template>
  </div>
</template>
<script>
/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import New from './components/New.vue';
export default {
  name: "Mine1View",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      sampleD: "value",
      booms: [0, 1, 1, 2, 2, 1, 1, 9, 9],
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {},
  methods: {
    sampleM() {},
    //生成雷区
    generate() {
      // this.$message.success("hihi");
      let p = [];
      let boomLength = 11;
      let boomNum = 2;
      //初始化 0
      for (let i = 0; i < boomLength; i++) {
        p[i] = 0;
      }

      // 随机布雷
      for (let i = 0; i < boomNum; ) {
        let w = Math.floor(Math.random() * boomLength);
        if (p[w] === 9) {
          continue;
        }
        p[w] = 9;
        i++;
      }

      console.log(p);
      this.booms = p;
    },
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
